# enums.py

#!/usr/bin/python3
# -*- coding: utf-8 -*-
# @Desc: { 项目枚举类模块 }
from enum import Enum

class StatusCodeEnum(Enum):
    """状态码枚举类"""

    OK = (1000, '成功')
    OK_SEND = (1001, '发送成功,请前往邮箱查看验证码')
    OK_SIGN = (1002, '注册成功,即将跳转到登录页面')
    OK_CHANGE = (1003, '修改成功,即将跳转到登录页面')
    OK_USER = (1004, '用户名存在')
    OK_GET = (1005, '开始获取书籍')

    ERROR = (-1, '错误')
    SERVER_ERR = (500, '服务器异常')

    IMAGE_CODE_ERR = (4001, '未完成人机验证!')
    THROTTLING_ERR = (4002, '访问过于频繁')
    NECESSARY_PARAM_ERR = (4003, '缺少必传参数')
    USER_ERR = (4004, '用户名错误')
    USER_CF = (4005, '用户名已存在')
    PWD_ERR = (4006, '密码错误')
    CPWD_ERR = (4007, '密码不一致')
    MOBILE_ERR = (4008, '手机号格式错误')
    MOBILE_CF = (4009, '手机号已存在')
    SMS_CODE_ERR = (4010, '短信验证码有误')
    ALLOW_ERR = (4011, '未勾选协议')
    SESSION_ERR = (4012, '用户未登录')
    REGISTER_FAILED_ERR = (4013, '注册失败')
    EM_CODE_ERR = (4014, '验证码还在有效期内,请勿重复生成')
    EM_NULL_ERR = (4015, '邮箱不能为空')
    EM_SEND_ERR = (4016, '验证码发送失败')
    EM_SENDNULL_ERR = (4017, '请先获取验证码或检查输入是否正确')
    EM_OUT_ERR = (4018, '验证码已过期,请重新获取')
    PWD_CHANGE_ERR = (4019, '密码修改失败')
    SIGN_ERR = (4020, '填写数据后再进行注册')
    LOGIN_ERR = (4021, '用户名或密码错误')

    DB_ERR = (5000, '数据库错误')
    EMAIL_ERR = (5001, '邮箱错误')
    TEL_ERR = (5002, '固定电话错误')
    NODATA_ERR = (5003, '无数据')
    NEW_PWD_ERR = (5004, '新密码错误')
    OPENID_ERR = (5005, '无效的openid')
    PARAM_ERR = (5006, '参数错误')
    STOCK_ERR = (5007, '库存不足')
    DB_ERR_UP_TYPE = (5008, '电子书分类更新失败')

    @property
    def code(self):
        """获取状态码"""
        return self.value[0]

    @property
    def errmsg(self):
        """获取状态码信息"""
        return self.value[1]

